/**
 * 
 */
package gameTypes;

/**
 * @author Elliott
 *
 */
public class Vector2 {
	public float x,y;
	
	public Vector2() {
		x = y = 0;
	}
	
	public Vector2(float x, float y) {
		this.x = x;
		this.y = y;
	}
	
	public Vector2 set(float x, float y) {
        this.x = x;
        this.y = y;
        return this;
    }
    
    public Vector2 set(Vector2 other) {
        this.x = other.x;
        this.y = other.y;
        return this;
    }
    
    public Vector2 add(float x, float y) {
        this.x += x;
        this.y += y;
        return this;
    }
    
    public Vector2 add(Vector2 other) {
        this.x += other.x;
        this.y += other.y;
        return this;
    }
    
    public Vector2 sub(float x, float y) {
        this.x -= x;
        this.y -= y;
        return this;
    }
    
    public Vector2 sub(Vector2 other) {
        this.x -= other.x;
        this.y -= other.y;
        return this;
    }
    
    @Override
	public boolean equals(Object obj) {
    	if((obj == null) || (obj.getClass() != this.getClass()))
            return false;

    	Vector2 v = (Vector2)obj;
    	
    	if (v.x == this.x && v.y == this.y)
    		return true;
    	
    	return false;
	}
    
    @Override
    public int hashCode() {
    	return (int) (((x + y)*(x + y) + x - y)/2);
    }
}
